package com.xpffly.design.decorator.common;

import com.xpffly.design.decorator.common.service.Component;
import com.xpffly.design.decorator.common.service.impl.ConcreteComponent;
import com.xpffly.design.decorator.common.service.impl.ConcreteDecorator1;
import com.xpffly.design.decorator.common.service.impl.ConcreteDecorator2;

/**
 * @Author: xpengfei
 * @Date: 2021/4/8 23:41
 * @Description：装饰模式通用代码
 */
public class Scene {
    public static void main(String[] args) {
        // 目标对象，被装饰者
        Component component = new ConcreteComponent();
        // 第一次装饰
        component = new ConcreteDecorator1(component);
        // 第二次装饰
        component = new ConcreteDecorator2(component);
        //装饰后运行
        component.operate();
    }
}
